import { BaseContentBlock } from "./base.js";

export type Multimodal = never;

export const KNOWN_BLOCK_TYPES = [
  "image",
  "video",
  "audio",
  "text-plain",
  "file",
];

// eslint-disable-next-line @typescript-eslint/no-namespace
export declare namespace Multimodal {
  type BaseDataRecord = {
    /**
     * MIME type of the file.
     *
     * @see https://www.iana.org/assignments/media-types/media-types.xhtml#image
     */
    mimeType?: string | undefined;
  };
  type DataRecordFileId = BaseDataRecord & {
    /**
     * ID of the data file, e.g. from a provider's file api
     */
    fileId: string;
    url?: never;
    data?: never;
  };
  type DataRecordUrl = BaseDataRecord & {
    fileId?: never;
    /**
     * URL of the data file
     */
    url: string;
    data?: never;
  };
  type DataRecordBase64 = BaseDataRecord & {
    fileId?: never;
    url?: never;
    /**
     * MIME type of the file. Required for base64 encoding.
     *
     * @see https://www.iana.org/assignments/media-types/media-types.xhtml#image
     */
    mimeType: string;
    /**
     * Base64 encoded string or binary data of the data
     */
    data: string | Uint8Array;
  };
  type DataRecord = DataRecordFileId | DataRecordUrl | DataRecordBase64;

  /** Content block for multimodal data */
  export type Data<TMetadata = Record<string, unknown>> = BaseContentBlock &
    DataRecord & {
      /**
       * MIME type of the file. Required for base64 encoding.
       */
      mimeType?: string;
      /**
       * Metadata of the file
       */
      metadata?: TMetadata;
      /**
       * Content block identifier for multimodal content, e.g. image, video, audio, file or plain text. This can be either:
       *  - generated by the provider (e.g., an OpenAI block ID)
       *  - generated by LangChain upon creation
       */
      id?: string;
    };

  /** Content block for image data */
  export type Image = Data & {
    /** Type of the content block */
    readonly type: "image";
  };
  /** Content block for video data */
  export type Video = Data & {
    /** Type of the content block */
    readonly type: "video";
  };
  /** Content block for audio data */
  export type Audio = Data & {
    /** Type of the content block */
    readonly type: "audio";
  };
  /** Content block for plain text data */
  export type PlainText = Data & {
    /** Type of the content block */
    readonly type: "text-plain";
    /**
     * Plaintext content. This is optional if the data is base64 encoded.
     */
    text?: string;
    /**
     * Title of the file, e.g. the title of a document
     */
    title?: string;
    /**
     * Context for the text, e.g. a description or a summary of the text's content
     */
    context?: string;
  };

  /** Content block for file data */
  export type File = Data & {
    /**
     * Non-descript multimodal content block
     *
     * This block is intended for files that aren't covered by existing content block types.
     */
    readonly type: "file";
  };

  export type Standard = Image | Video | Audio | PlainText | File;
}
